package cn.edu.sasu.controller;

import cn.edu.sasu.common.annotation.RoleNum;
import cn.edu.sasu.common.base.RespResult;
import cn.edu.sasu.common.constants.Role;
import cn.edu.sasu.domain.dto.LoginFormDTO;
import cn.edu.sasu.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


@RestController
public class LoginController {

    @Autowired
    private SysUserService sysUserService;

    @RoleNum(Role.COMMON)
    @GetMapping("/login")
    public RespResult login(HttpServletResponse response, @Validated LoginFormDTO loginFormDTO){
        return sysUserService.login(response,loginFormDTO.getUsername(),loginFormDTO.getPassword());
    }

}
